﻿// Decompiled with JetBrains decompiler
// Type: TaleWorlds.CampaignSystem.LogEntries.CommonAreaFightLogEntry
// Assembly: TaleWorlds.CampaignSystem, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E85F8C15-4DF6-4E9C-A58A-29177E40D07A
// Assembly location: D:\steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll

using System.Collections.Generic;
using TaleWorlds.CampaignSystem.Party;
using TaleWorlds.CampaignSystem.Settlements;
using TaleWorlds.Localization;
using TaleWorlds.ObjectSystem;
using TaleWorlds.SaveSystem;

#nullable disable
namespace TaleWorlds.CampaignSystem.LogEntries
{
  public class CommonAreaFightLogEntry : LogEntry, IEncyclopediaLog
  {
    [SaveableField(170)]
    private readonly TextObject _attackerName;
    [SaveableField(171)]
    private readonly TextObject _defenderName;
    [SaveableField(172)]
    private readonly Settlement _settlement;

    internal static void AutoGeneratedStaticCollectObjectsCommonAreaFightLogEntry(
      object o,
      List<object> collectedObjects)
    {
      ((LogEntry) o).AutoGeneratedInstanceCollectObjects(collectedObjects);
    }

    protected override void AutoGeneratedInstanceCollectObjects(List<object> collectedObjects)
    {
      base.AutoGeneratedInstanceCollectObjects(collectedObjects);
      collectedObjects.Add((object) this._attackerName);
      collectedObjects.Add((object) this._defenderName);
      collectedObjects.Add((object) this._settlement);
    }

    internal static object AutoGeneratedGetMemberValue_attackerName(object o)
    {
      return (object) ((CommonAreaFightLogEntry) o)._attackerName;
    }

    internal static object AutoGeneratedGetMemberValue_defenderName(object o)
    {
      return (object) ((CommonAreaFightLogEntry) o)._defenderName;
    }

    internal static object AutoGeneratedGetMemberValue_settlement(object o)
    {
      return (object) ((CommonAreaFightLogEntry) o)._settlement;
    }

    public CommonAreaFightLogEntry(
      MobileParty attackerParty,
      MobileParty defenderParty,
      Hero attackerHero,
      Settlement settlement)
    {
      this._attackerName = attackerParty != null ? attackerParty.Name : attackerHero.Name;
      this._defenderName = defenderParty.Name;
      this._settlement = settlement;
    }

    public override string ToString() => this.GetEncyclopediaText().ToString();

    public bool IsVisibleInEncyclopediaPageOf<T>(T obj) where T : MBObjectBase
    {
      return (object) obj == this._settlement;
    }

    public TextObject GetEncyclopediaText()
    {
      TextObject encyclopediaText = new TextObject("{=A3ql1SUy}{PARTY_1} attacked a common area belonging to {PARTY_2} in {SETTLEMENT}.");
      encyclopediaText.SetTextVariable("PARTY_1", this._attackerName);
      encyclopediaText.SetTextVariable("PARTY_2", this._defenderName);
      encyclopediaText.SetTextVariable("SETTLEMENT", this._settlement.EncyclopediaLinkWithName);
      return encyclopediaText;
    }
  }
}
